package com.kapcb.mvc.validator;

import cn.hutool.core.util.ReUtil;
import cn.hutool.http.HtmlUtil;
import com.kapcb.mvc.annotation.Xss;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * <a>Title: XssValidator </a>
 * <a>Author: kapcb <a>
 * <a>Description: XssValidator <a>
 * 自定义 xss 校验注解实现
 *
 * @author Kpacb
 * @version 1.0
 * @date 2024/6/13 20:09
 * @since 1.0
 */
public class XssValidator implements ConstraintValidator<Xss, String> {

    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        return !ReUtil.contains(HtmlUtil.RE_HTML_MARK, value);
    }

}
